//
//  LHillnessView.m
//  QuickCure
//
//  Created by 小灰灰 on 16/9/12.
//  Copyright © 2016年 haoge. All rights reserved.
//

#import "LHillnessView.h"
@interface LHillnessView()
@property(nonatomic,strong)UILabel *QZtextLabel;
@property(nonatomic,weak)UIButton *selectedBtn;
@property(nonatomic,copy)NSString *btnStr;

@end

@implementation LHillnessView
-(void)addLabelWithPatientInfo:(NSString *)patientInfo illnessType:(NSString *)illnessType
{
    //病人信息label
    UILabel *patientInfoLable =[[UILabel alloc] initWithFrame:CGRectMake(15, 80,SCREEN_LEFT_WIDTH , 20)];
    //NSString *patientInfo = patientInfo;
    patientInfoLable.text = [NSString stringWithFormat:@"用户信息：  %@",patientInfo];
    //疾病类型label
    UILabel *illnessLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 105, SCREEN_LEFT_WIDTH, 20)];
    illnessLabel.text =[NSString stringWithFormat:@"疾病类型：  %@",illnessType];
//    //就医申请button
//    UIButton *applyBtn =[[UIButton alloc] init];
//    [self addSubview:applyBtn];
//    [applyBtn setBackgroundColor:kThemeColor];
//    applyBtn.layer.cornerRadius = 3;
//    applyBtn.clipsToBounds = YES;
//    [applyBtn addTarget:self action:@selector(applyBtnClick) forControlEvents:UIControlEventTouchUpInside];
//    [applyBtn setTitle:@"就医申请" forState:UIControlStateNormal];
//    [applyBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
//    [applyBtn mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.bottom.right.mas_equalTo(self).offset(-10);
//        make.left.mas_equalTo(self).offset(10);
//        make.height.mas_equalTo(@40);
//    }];
//    //医生头像image
//    UIImageView *docImg =[[UIImageView alloc] init];
//    [self addSubview:docImg];
//    docImg.image =[UIImage imageNamed:@"illness_img_person.png"];
//    [docImg mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.centerX.mas_equalTo(self);
//        make.width.height.equalTo(@80);
//        make.bottom.mas_equalTo(applyBtn.mas_top).offset(-20);
//        
//    }];
//    //匹配label
//    UILabel *matchLabel = [[UILabel alloc] init];
//    [self  addSubview:matchLabel];
//    matchLabel.text =  @"为您匹配到：42位医生";
//    matchLabel.textAlignment = NSTextAlignmentCenter;
//    [matchLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.right.mas_equalTo(self);
//        make.height.mas_equalTo(@40);
//        make.bottom.mas_equalTo(docImg.mas_top).offset(-20);
//    }];


    [self addSubview:patientInfoLable];
    [self addSubview:illnessLabel];
}
-(void)addSubViewsWithLabelText:(NSString *)textLabelStr
{
    //设置文字和图片
    UILabel *textLabel =[[UILabel alloc] init];
    [textLabel setText:textLabelStr];
    self.label = textLabel;
    [textLabel setTextColor:[UIColor colorWithRed:0.8373 green:0.8333 blue:0.8414 alpha:1.0]];
    [self addSubview:textLabel];
    [textLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.mas_equalTo(self).offset(10);
        make.right.mas_equalTo(self).offset(-40);
    }];
    
    //竖线和箭头的view
    UIView *smallView =[[UIView alloc] init];
    [self addSubview:smallView];
    smallView.backgroundColor =[UIColor whiteColor];
    [smallView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(textLabel.mas_right).offset(0);
        make.right.mas_equalTo(self).offset(0);
        make.top.mas_equalTo(self).offset(5);
        make.height.mas_equalTo(self).multipliedBy(0.8);
    }];
    //竖线
    UIImageView *lineImage=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"illness_img_line.png"]];
    [smallView addSubview:lineImage];
    [lineImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(smallView).offset(0);
        make.right.mas_equalTo(smallView).offset(-38);
        make.top.mas_equalTo(smallView).offset(5);
        make.bottom.mas_equalTo(smallView).offset(-5);
    }];
    //箭头按钮
    UIButton *input =[[UIButton alloc] init];
    [smallView addSubview:input];
    [input setImage:[UIImage imageNamed:@"illness_button_input_blue.png" ] forState:UIControlStateNormal];
    [input mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(lineImage.mas_right).offset(10);
        make.top.bottom.mas_equalTo(smallView).offset(0);
        make.right.mas_equalTo(smallView).offset(-5);
    }];
  
}
-(void)addSubViewsWithLabelText:(NSString *)textLabelStr btnStr:(NSString *)btnStr anotherBtnStr:(NSString *)anotherBtnStr{
    //设置文字和图片
    UILabel *textLabel =[[UILabel alloc] init];
    self.QZtextLabel = textLabel;
    [textLabel setText:textLabelStr];
    [textLabel setTextColor:[UIColor colorWithRed:0.8373 green:0.8333 blue:0.8414 alpha:1.0]];
    
    [self addSubview:textLabel];
    [textLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.mas_equalTo(self).offset(10);
        make.right.mas_equalTo(self).multipliedBy(0.5);
    }];
    
    //已确诊按钮
    UIButton *qzBtn = [self btnTitle:btnStr monsonry:textLabel superView:self];
    //症状疑似按钮
    [self btnTitle:anotherBtnStr monsonry:qzBtn superView:self];
    
    
}
-(UIButton *)btnTitle:(NSString *)titleStr monsonry:(UIView *)view superView:(UIView *)superView
{
    //已确诊按钮
    UIButton *btn =[[UIButton alloc] init];
    [superView addSubview:btn];
    [btn addTarget:self action:@selector(clickBtn:) forControlEvents:UIControlEventTouchUpInside];
    [btn setImage:[UIImage imageNamed:@"illness_rb_img_nor.png"] forState:UIControlStateNormal];
    [btn setImage:[UIImage imageNamed:@"illness_rb_img_sel.png"] forState:UIControlStateSelected];
    [btn setTitle:titleStr forState:UIControlStateNormal];
    btn.font =[UIFont systemFontOfSize:15];
    [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(view);
        make.left.mas_equalTo(view.mas_right);
        make.width.mas_equalTo(@80);
        make.top.bottom.mas_equalTo(superView);
    }];
    return btn;
}

-(void)clickBtn:(UIButton *)btn
{
    self.btnStr = btn.titleLabel.text;
    self.selectedBtn.selected = NO;
    self.selectedBtn = btn;
    btn.selected = YES;
    //改变label上的文字
    self.QZtextLabel.text = self.btnStr;
    [self.QZtextLabel setTextColor:[UIColor blackColor]];

    if(self.textBlock)
    {
        self.textBlock(self.QZtextLabel.text);
    }
  
}


 
@end
